package com.group.eams.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.eams.pojo.dto.FlowNodeQueryDto;
import com.group.eams.pojo.entity.FlowNode;
import com.group.eams.service.FlowNodeService;
import com.group.eams.mapper.FlowNodeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 恩哲欣
* @description 针对表【flow_node(流程节点表)】的数据库操作Service实现
* @createDate 2024-10-29 16:09:34
*/
@Service
public class FlowNodeServiceImpl extends ServiceImpl<FlowNodeMapper, FlowNode> implements FlowNodeService{

    @Autowired
    private FlowNodeMapper flowNodeMapper;

    /**
     * 根据查询条件查询流程节点
     *
     * @param flowNodeQueryDto 查询条件
     * @return 流程节点列表
     */
    @Override
    public Page<FlowNode> findByQueryDto(FlowNodeQueryDto flowNodeQueryDto) {
        Page<FlowNode> page = new Page<>(flowNodeQueryDto.getPage(), flowNodeQueryDto.getLimit());
        LambdaQueryWrapper<FlowNode> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(!StrUtil.isEmpty(flowNodeQueryDto.getName()), FlowNode::getName, flowNodeQueryDto.getName());
        return flowNodeMapper.selectPage(page, queryWrapper);
    }
}
